namespace GeoBox.Database.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Device",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.GpsPoint",
                c => new
                    {
                        DeviceId = c.Int(nullable: false),
                        UtcTime = c.DateTime(nullable: false),
                        Latitude = c.Double(nullable: false),
                        Longitude = c.Double(nullable: false),
                    })
                .PrimaryKey(t => new { t.DeviceId, t.UtcTime })
                .ForeignKey("dbo.Device", t => t.DeviceId, cascadeDelete: true)
                .Index(t => t.DeviceId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.GpsPoint", new[] { "DeviceId" });
            DropForeignKey("dbo.GpsPoint", "DeviceId", "dbo.Device");
            DropTable("dbo.GpsPoint");
            DropTable("dbo.Device");
        }
    }
}
